package com.epam.controller;

import com.epam.Model.CreateOrderModel;
import com.epam.Model.OrderResponseModel;
import com.epam.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "searchOrder", method = RequestMethod.POST)
    @ResponseBody
    public OrderResponseModel searchOrder(String orderId){
        return orderService.searchOrder(orderId);
    }

    @RequestMapping(value = "createOrder", method = RequestMethod.POST)
    @ResponseBody
    public OrderResponseModel createOrder(@RequestBody CreateOrderModel order){
        OrderResponseModel res = orderService.createOrder(order);
        return res;
    }
}
